import tushare as ts
from pymongo import MongoClient

stocks = ts.get_stock_basics()
stocks = stocks.sort_index()
codes = stocks.index.tolist()


def get_db():
    client = MongoClient("localhost", 27017)
    db = client.stock
    return db

db = get_db()
db.info.insert({'name': 'stock_list', 'value':codes})